package com.hns.phone.maintenance.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hns.can.common.constants.GlobalConst;
import com.hns.can.common.formula.FillCodeDscValue;
import com.hns.can.common.formula.FillParamsVo;
import com.hns.can.common.service.CommonInitParamService;
import com.hns.can.common.vo.CommonParamsVo;
import com.hns.can.master.entity.CommCarCurrentLoInfoEntity;
import com.hns.frame.service.CommonService;
import com.hns.phone.common.vo.CommDriveTrajInfoVo;
import com.hns.phone.entity.CommDriveTrajInfoEntity;
import com.hns.tool.pub.PubUtil;


/**
 * @版权：HNS 版权所有 (c) 2013
 * @author:zhangy
 * @version Revision 1.0.0
 * @email:zhangyu2222z@sina.cn
 * @see:
 * @创建日期：2015年4月2日
 * @功能说明：行驶记录service
 * @begin
 * @修改记录:
 * @修改后版本          修改人      	修改内容
 * @2015年4月2日  	       zhangy       	创建
 * @end
 */
@Service
public class PhoneDriveRecordService extends CommonService{
	
	
	@Autowired
    private FillCodeDscValue codeDscValue;
	
	
	@SuppressWarnings("unchecked")
	public List<CommDriveTrajInfoVo> getDriveTrajInfoForMobile(CommonParamsVo entity) throws Exception{
		List<CommDriveTrajInfoVo> selectList = PubUtil
				.convertListMapToObject(sqlMapDao.selectList(
						"phoneDriveRecord.getDriveTrajInfoForMobile", entity),
						CommDriveTrajInfoVo.class);
		Map<String,String> map = new HashMap<String,String>();
		map.put("licPltNo", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo = new FillParamsVo("carId", map);
        codeDscValue.fillInfoValue(selectList,new String[]{GlobalConst.CACHE_KEY_BASE_CAR_INFO},vo);
		return selectList;
	}
	
	/**
	 * @param entity
	 * @param request
	 * @param commonInitParamService
	 * @return
	 * @throws QueryExprException
	 * @author:zhangy
	 * @email:zhangyu2222z@sina.cn
	 * @创建日期:2015年4月16日
	 * @功能说明：获取指定车辆末次位置
	 */
	@SuppressWarnings("unchecked")
	@Transactional
	public List<CommCarCurrentLoInfoEntity> getLastTrajInfoForMobile(CommonParamsVo entity,
			HttpServletRequest request, CommonInitParamService commonInitParamService) {
		List<CommCarCurrentLoInfoEntity> selectList = PubUtil
				.convertListMapToObject(sqlMapDao.selectList(
						"phoneDriveRecord.getLastTrajInfoForMobile", entity),
						CommCarCurrentLoInfoEntity.class);
		return selectList;
	}

	@SuppressWarnings("unchecked")
	public List ff(CommonParamsVo entity) throws Exception{
		List selectList = sqlMapDao.selectList("phoneDriveRecord.getDriveTrajInfoForMobile", entity);
//		List<CommDriveTrajInfoEntity> selectList = PubUtil
//				.convertListMapToObject(,
//						CommDriveTrajInfoEntity.class);
//		
//		Map<String,String> map = new HashMap<String,String>();
//		map.put("licPltNo", GlobalConst.DEFAULT_CACHE_VALUE);
//        FillParamsVo vo = new FillParamsVo("carId", map);
//        codeDscValue.fillInfoValue(selectList,new String[]{GlobalConst.CACHE_KEY_BASE_CAR_INFO},vo);
		return selectList;
//		return null;
	}
	
	
}
